package net.swl.linkedvillage;

import java.util.ArrayList;
import java.util.List;

import net.swl.linkedvillage.entity.PrestacaoServico;
import net.swl.linkedvillage.util.GestorParse;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;

import com.parse.FindCallback;
import com.parse.ParseException;
import com.parse.ParseObject;

public class MeusServicosActivity extends Activity {

	private List<PrestacaoServico> servicosEmCurso = new ArrayList<PrestacaoServico>();
	private List<PrestacaoServico> servicosPendentes = new ArrayList<PrestacaoServico>();
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_meus_servicos);
		getActionBar().setIcon(R.drawable.logo_linkedvillage);
		setTitle("");
		GestorParse gestorParse = new GestorParse(this);
		gestorParse.getServicosEmCursoUser(new FindCallback<ParseObject>() {
			@Override
			public void done(List<ParseObject> arg0, ParseException arg1) {
				setServicosEmCurso(arg0);
			}
		});
		
		gestorParse.getServicosEmCursoUser(new FindCallback<ParseObject>() {
			@Override
			public void done(List<ParseObject> arg0, ParseException arg1) {
				setServicosPendentes(arg0);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.meus_servicos, menu);
		return true;
	}
	
	public void setServicosEmCurso(List<ParseObject> objs) {
		for (ParseObject parseObject : objs) {
			servicosEmCurso.add(new PrestacaoServico(parseObject));
		}
	}
	
	public void setServicosPendentes(List<ParseObject> objs) {
		for (ParseObject parseObject : objs) {
			servicosPendentes.add(new PrestacaoServico(parseObject));
		}
	}

}
